home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / eiffel / smalleif.97 / se.t / SmallEiffel / lib_test / test_array_reference1.e < prev    next >
Encoding:
Text File  |  1996-05-02  |  2.8 KB  |  148 lines

  1. -- Part of SmallEiffel -- Read DISCLAIMER file -- Copyright (C) 
  2. -- Dominique COLNET and Suzanne COLLIN -- colnet@loria.fr
  3. --
  4. class TEST_ARRAY_REFERENCE1
  5. --
  6. -- Test Reference/ARRAY.
  7. --
  8.    
  9. creation {ANY}
  10.    make
  11.    
  12. feature {ANY}
  13.    
  14.    a, a2: ARRAY[CAT];
  15.    c1,c2,c3,cv: CAT;
  16.    i: INTEGER;
  17.    
  18.    a_cat: ARRAY[CAT];
  19.    a_animal: ARRAY[ANIMAL];
  20.    
  21.    make is
  22.       do
  23.      !!c1;
  24.      !!c2;
  25.      !!c3;
  26.      
  27.      !!a.make(1,0);
  28.      is_true(a.lower = 1);
  29.      is_true(a.upper = 0);
  30.      is_true(a.count = 0);
  31.      is_true(a.empty);
  32.      a.make(1,1);
  33.      is_true(a.count = 1);
  34.      is_true(a.lower = 1);
  35.      is_true(a.upper = 1);
  36.      is_true(a.item(1) = Void);
  37.      
  38.      !!a.make(1,4);
  39.      is_true(a.count = 4);
  40.      from  
  41.         i := 1;
  42.      until
  43.         i > a.count
  44.      loop
  45.         is_true(a.item(i) = Void);
  46.         i := i + 1;
  47.      end;
  48.  
  49.      !!a.make(-3,-2);
  50.      is_true(a.count = 2);
  51.      is_true(not a.empty);
  52.      is_true(a.lower = -3);
  53.      is_true(a.upper = -2);
  54.      a.put(c1,-3);
  55.      a.put(c2,-2);
  56.      is_true(a.item(-3) = c1);
  57.      is_true(a.item(-2) = c2);
  58.      
  59.      !!a.make(-1,-2);
  60.      is_true(a.count = 0);
  61.      is_true(a.empty);
  62.      is_true(a.lower = -1);
  63.      a.add_last(c1);
  64.      is_true(a.count = 1);
  65.      is_true(a.item(-1) = c1);
  66.      
  67.      a := <<c1>>;
  68.      is_true(a.count = 1);
  69.      is_true(a.lower = 1);
  70.      is_true(a.upper = 1);
  71.      is_true(a.item(1) = c1);
  72.      a.add_last(c2);
  73.      is_true(a.count = 2);
  74.      is_true(a.item(1) = c1);
  75.      is_true(a.item(2) = c2);
  76.            
  77.      !!a.make(1,3);
  78.          a.put(c2,2);
  79.            
  80.      !!a.make(1,3); 
  81.      a.put(c1,1);
  82.      a.put(c2,2);
  83.      a.put(c3,3);
  84.      is_true(equal(a,<<c1,c2,c3>>));
  85.      a.resize(0,4);
  86.      is_true(a.item(0) = Void);
  87.      is_true(a.item(1) = c1);
  88.      is_true(a.item(2) = c2);
  89.      is_true(a.item(3) = c3);
  90.      is_true(a.item(4) = Void);
  91.            
  92.      a := <<c1,c2,c3>>;
  93.      a.resize(0,4);
  94.      is_true(a.item(0) = Void);
  95.      is_true(a.item(1) = c1);
  96.      is_true(a.item(2) = c2);
  97.      is_true(a.item(3) = c3);
  98.      is_true(a.item(4) = Void);
  99.       
  100.      a2 := <<c1>>;
  101.      a := clone(a2);
  102.      is_true(a.count = 1);
  103.      is_true(a2.count = 1);
  104.      is_true(a.item(1) = c1);
  105.      a2.put(c2,1);
  106.      is_true(a2.item(1) = c2);
  107.      is_true(a.item(1) = c1);
  108.      
  109.      a := <<c1,c2,c3>>;
  110.      a2 := clone(a);
  111.      is_true(equal(a,a2));
  112.      a.put(Void,2);
  113.      is_true(not equal(a,a2));
  114.       
  115.      !!a.make(1,3);
  116.      a.put(c2,2);
  117.      is_true(equal(a,<<Void,c2,Void>>));
  118.      a.put(Void,2);
  119.      is_true(not equal(a,<<Void,c2,Void>>));
  120.      a.make(1,3);
  121.      is_true(a.item(1) = Void);
  122.      is_true(a.item(2) = Void);
  123.      is_true(a.item(3) = Void);
  124.      
  125.      !!a.make(2,2);
  126.      a.force(c1,1);
  127.      is_true(equal(a,<<c1,Void>>));
  128.      a.force(c3,3);
  129.      is_true(equal(a,<<c1,Void,c3>>));
  130.       
  131.       end;
  132.    
  133.    is_true(b: BOOLEAN) is
  134.       do
  135.      cpt := cpt + 1;
  136.      if not b then
  137.         std_output.put_string("TEST_ARRAY_REFERENCE : ERROR Test # ");
  138.         std_output.put_integer(cpt);
  139.         std_output.put_string("%N");
  140.      else
  141.         -- std_output.put_string("Yes%N");
  142.      end;
  143.       end;
  144.    
  145.    cpt: INTEGER;
  146.    
  147. end -- class TEST_ARRAY_REFERENCE1
  148.